﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Fantacid303.ProcessAffinityControl.Manager.MainWindowViewModels;

namespace Fantacid303.ProcessAffinityControl.Manager
{
	/// <summary>
	/// Interaction logic for TestWindow.xaml
	/// </summary>
	public partial class TestWindow : Window
	{
		private bool allowClose = false;

		public TestWindow()
		{
			InitializeComponent();
		}

		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			this.trayIcon.TrayLeftMouseUp += new RoutedEventHandler(trayIcon_TrayLeftMouseUp);
		}

		void trayIcon_TrayLeftMouseUp(object sender, RoutedEventArgs e)
		{
			this.Visibility = (this.Visibility==Visibility.Visible)? Visibility.Collapsed: Visibility.Visible;
		}

		protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
		{
			e.Cancel = !this.allowClose;

			this.Visibility = System.Windows.Visibility.Hidden;


			this.trayIcon.ShowBalloonTip("Fantacid303's Process Affinity Control", "The program has been minimized. Click on this icon to show the program again.", this.trayIcon.Icon);

			base.OnClosing(e);
		}

		private void mnuExit_Click(object sender, RoutedEventArgs e)
		{
			this.allowClose = true;
			this.Close();
		}
	}
}
